//app.js
let api = new (require('/utils/api.js'))
App({

  onShow(e){
    console.log(e,'onshow');
    
  },
  onLaunch: function () {
    console.log('onLaunch');
    wx.login({
      success: res => {
        console.log(res,'app.wxlogin');
        api.wxlogin(res.code, res => {
          console.log(res,'app.wxlogin2222222');
          this.logininfo = res.data;
         // this.token=res.data.Token;
          wx.setStorage({
            key: 'openid',
            data: res.data.openid,
          });
          wx.setStorage({
            key: 'userinfo',
            data: JSON.stringify(res.data.user),
          })
          wx.setStorage({
            key: 'type',
            data: res.data.type,
          })
          wx.setStorage({
            key: 'isnine',
            data: res.data.isnine,
          })
          
        })
      },
      complete:res=>{
        console.log(res,'res--com');
      }
    })  
},
  badege: function (cart) {
    let cartlength = cart.length;
    cartlength = String(cartlength);
    // console.log(cart, "cart");
    console.log(cartlength,"cartlength");
    // if (cartlength > 0) {
    //   wx.setTabBarBadge({
    //     index: 3,
    //     text: cartlength,
    //   })
    // } else {
    //   wx.removeTabBarBadge({
    //     index: 3,
    //   })
    // }
  },

  getsetting() {
    api.getsetting(res => {
      if (res.data.issuccess == 1) {
        let setting = res.data.data;
        wx.setStorageSync("setting",setting)
      }
    });
  },
  circleplaysrc:'',
  globalData: {
    userinfo: null
  }
})